package Servlet;

import Shiti.Shopti;
import Shiti.Userti;
import service.Shopservice;
import service.Userservice;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;
@WebServlet("/changeshopnameservlet")
public class changeshopnameservlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        request.setCharacterEncoding("utf-8");
        response.setContentType("text/html;utf-8");
        response.setCharacterEncoding("utf-8");
        PrintWriter out = response.getWriter();
        int id= Integer.parseInt(request.getParameter("id1"));
        String bus =request.getParameter("bus1");
        String newname = request.getParameter("name2");
        String name =request.getParameter("name1");
        Shopti shopti=new Shopti(id,name,bus);
        Shopservice shopservice =new Shopservice();
        boolean a= shopservice.changename(shopti,newname);
        if (a) {
            out.println("修改成功");
        }else {
            out.println("修改失败");
        }
    }
    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        doGet(req, resp);
    }
}
